package com.liaoban.app.ui.rank;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.liaoban.app.R;
import com.liaoban.app.ui.MainActivity;
import com.liaoban.app.ui.base.BaseTabHostFragment;
import com.liaoban.app.util.CommonUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by ybc on 2018/7/13 0013.
 * 排行榜
 */
public class RankFragment extends BaseTabHostFragment {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_right)
    ImageView ivRight;

    @Override
    protected String[] getTitleList() {
        return new String[]{"魅力日榜", "魅力周榜", "魅力月榜", "富豪日榜", "富豪周榜", "富豪月榜"};
    }

    @Override
    protected Class[] getFragmentList() {
        return new Class[]{RankChildFragment.class, RankChildFragment.class, RankChildFragment.class, RankChildFragment.class, RankChildFragment.class, RankChildFragment.class};
    }

    @Override
    protected Bundle[] getBundles() {
        return new Bundle[]{RankChildFragment.getBundle("1"), RankChildFragment.getBundle("2"), RankChildFragment.getBundle("3"), RankChildFragment.getBundle("4"), RankChildFragment.getBundle("5"), RankChildFragment.getBundle("6"), };
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.fragment_rank;
    }

    @Override
    protected void initView(View contentView) {
        super.initView(contentView);
        toolbar.setNavigationOnClickListener(v -> {
            MainActivity mainActivity = (MainActivity) getActivity();
            mainActivity.changeTab(0);
        });//后退键
        tvTitle.setText("排行榜");
        ivRight.setImageResource(R.mipmap.ic_search_title);
        ivRight.setVisibility(View.VISIBLE);
        mainTab.setTabMode(TabLayout.LAYOUT_MODE_CLIP_BOUNDS);
        CommonUtils.setTabLayoutWidth(mainTab, 14);
    }

    @OnClick(R.id.iv_right)
    public void right() {
        startActivity(new Intent(getActivity(), SearchActivity.class));
    }
}
